package org.cloud.framework.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;

@Controller
@RequestMapping("/")
public class TemplateController {

    @RequestMapping("/{siteName}/{pageName}.html")
    public String webTemplate(@PathVariable("siteName") String siteName,
                              @PathVariable("pageName") String pageName, ModelMap model)
            throws IOException {


        System.out.println("siteName=" + siteName + "/pageName=" + pageName);

        //#获取网站文件变量
        model.addAttribute("ocFilePath", "/" + siteName);

        return  siteName + "/" + pageName;
    }


    /**
     * 测试beetl模板
     *
     * @return
     */
    @RequestMapping("/add")
    public ModelAndView home() {

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("email", "1111@1631111.com||||");
        modelAndView.setViewName("add");

        return modelAndView;
    }

}
